{# SPDX-License-Identifier: Apache-2.0 -#}
{% extends "base.html" %}
{% block title %}
  {% trans %}Manage{% endtrans %}
{% endblock %}
{# These pages are not indexed so the canonical URL doesn't matter #}
{% block canonical_url %}{% endblock %}
{# Hide mobile search on manager pages #}
{% block mobile_search %}{% endblock %}
{% macro twofa_section() %}
  <section id="two-factor">
    <h2 class="sub-title">{% trans %}Two factor authentication (2FA){% endtrans %}</h2>
    <p>
      {% trans href='/help#twofa' %}Two factor authentication adds an additional layer of security to your account. <a href="{{ href }}">Learn more about <abbr title="two factor authentication">2FA</abbr></a>. Once 2FA is enabled, it cannot be disabled.{% endtrans %}
    </p>
    {% if user.has_recovery_codes %}
      <table class="table table--2fa">
        <caption class="sr-only">{% trans %}Recovery methods enabled{% endtrans %}</caption>
        <thead>
          <tr>
            <th scope="col" colspan="2">{% trans %}Recovery method{% endtrans %}</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <th scope="row">
              {% trans %}Recovery codes{% endtrans %} - {% trans generated_datetime=humanize(request.user.recovery_codes[0].generated, time="true") %}generated {{ generated_datetime }}{% endtrans %} ({% trans remaining=request.user.recovery_codes.filter_by(burned=None).count() %}{{ remaining }} unused{% endtrans %}).
            </th>
            <td class="table__align-right">
              <a href="{{ request.route_path('manage.account.recovery-codes.regenerate') }}"
                 class="button button--secondary">{% trans %}Regenerate{% endtrans %}</a>
            </td>
          </tr>
        </tbody>
      </table>
    {% endif %}
    {% if user.has_two_factor %}
      <table class="table table--2fa">
        <caption class="sr-only">{% trans %}Two factor authentication methods enabled{% endtrans %}</caption>
        <thead>
          <tr>
            <th scope="col" colspan="2">{% trans %}Two factor method{% endtrans %}</th>
          </tr>
        </thead>
        <tbody>
          {% if user.has_single_2fa %}
            <tr>
              <td colspan="2" class="table__no-bottom-border">
                <div class="callout-block callout-block--warning no-top-margin no-bottom-margin">
                  {% trans %}To remove this 2FA method, you must first add another method.{% endtrans %}
                </div>
              </td>
            </tr>
          {% endif %}
          {% if user.totp_secret %}
            <tr>
              <th scope="row">
                {% trans %}Authentication application (<abbr title="time-based one-time password">TOTP</abbr>){% endtrans %}
              </th>
              <td class="table__align-right">
                {% if user.totp_secret %}
                  <a href="{{ request.route_path('manage.account.totp-provision') }}"
                     class="button button--primary">Edit</a>
                {% endif %}
                {% if user.has_single_2fa %}
                  <button class="button"
                          disabled
                          title="{% trans %}Cannot remove last 2FA method{% endtrans %}">
                    {% trans %}Remove{% endtrans %}
                  </button>
                {% else %}
                  <a href="#disable-totp" class="button button--secondary">{% trans %}Remove{% endtrans %}</a>
                  {% set title = gettext("Remove authentication application") %}
                  {% set confirm_button_label = gettext("Remove application") %}
                  {% set action = request.route_path('manage.account.totp-provision') %}
                  {{ confirm_password_modal(title=title, action=action, slug="disable-totp", warning=False, confirm_button_label=confirm_button_label) }}
                {% endif %}
              </td>
            </tr>
          {% endif %}
          {% for credential in user.webauthn %}
            <tr>
              <th scope="row">
                <strong>"{{ credential.label }}"</strong> - {% trans %}Security device (<abbr title="web authentication">WebAuthn</abbr>){% endtrans %}
              </th>
              <td class="table__align-right">
                {% if user.has_single_2fa %}
                  <button class="button"
                          disabled
                          title="{% trans %}Cannot remove last 2FA method{% endtrans %}">
                    {% trans %}Remove{% endtrans %}
                  </button>
                {% else %}
                  <a href="#disable-webauthn-{{ credential.id }}"
                     class="button button--secondary">{% trans %}Remove{% endtrans %}</a>
                  {% set title = gettext("Remove two factor security device") + " - " + credential.label %}
                  {% set confirm_button_label = gettext("Remove device") %}
                  {% set action = request.route_path('manage.account.webauthn-provision.delete') %}
                  {% set slug = "disable-webauthn-" + credential.id | string %}
                  {% set extra_fields %}
                    <input type="hidden"
                           name="label"
                           value="{{ credential.label }}"
                           autocomplete="off">
                  {% endset %}
                  {{ confirm_modal(title=title, label=gettext("Device name") , confirm_name="device_name", confirm_string=credential.label, confirm_button_label=confirm_button_label, slug=slug, extra_fields=extra_fields, action=action, warning=False, confirm_string_in_title=False) }}
                {% endif %}
              </td>
            </tr>
          {% endfor %}
        </tbody>
      </table>
    {% endif %}
    {% if not user.has_primary_verified_email %}
      <div class="callout-block">
        <p>
          {% if user.has_two_factor %}
            {% trans href='#account-emails' %}
            <a href="{{ href }}">Verify your primary email address</a>
            before adding additional two factor authentication methods to your account.
          {% endtrans %}
        {% else %}
          {% trans href='#account-emails' %}
          <a href="{{ href }}">Verify your primary email address</a>
          before enabling two factor authentication on your account.
        {% endtrans %}
      {% endif %}
    </p>
  </div>
{% elif not user.has_recovery_codes %}
  <div class="callout-block">
    <p>
      {% if user.has_two_factor %}
        {% trans %}
        You must generate and safely store recovery codes before adding additional two factor
        authentication methods to your account.
      {% endtrans %}
    {% else %}
      {% trans %}
      You must generate and safely store recovery codes before enabling two factor authentication on your account.
    {% endtrans %}
  {% endif %}
</p>
<a href="{{ request.route_path('manage.account.recovery-codes.generate') }}"
   class="button button--primary">
  {% trans %}
  Generate recovery codes
{% endtrans %}
</a>
</div>
{% elif not user.has_burned_recovery_codes %}
<div class="callout-block">
  <p>
    {% if user.has_two_factor %}
      {% trans %}
      Use a recovery code before adding additional two factor
      authentication methods to your account.
    {% endtrans %}
  {% else %}
    {% trans %}
    Use a recovery code before enabling two factor authentication on your account.
  {% endtrans %}
{% endif %}
</p>
<p>
  This is in order to verify that you have safely stored your recovery codes for use in the event of a lost 2FA device.
</p>
<a href="{{ request.route_path('manage.account.recovery-codes.burn') }}"
   class="button button--primary">
  {% trans %}
  Use a recovery code
{% endtrans %}
</a>
</div>
{% endif %}
{% set disabled = not user.has_burned_recovery_codes or not user.has_primary_verified_email %}
{% if not disabled and not user.has_two_factor %}
  <div class="callout-block">
    <p>
      {% trans %}
      You have not enabled two factor authentication on your account.
    {% endtrans %}
  </p>
</div>
{% endif %}
<div class="wrap-children">
  <a href="{{ request.route_path('manage.account.totp-provision') }}"
     class="button button--primary {{ "button--disabled" if disabled or user.totp_secret else "" }}"
     title="{{ 'Only one authentication application (TOTP) can be used at a time' if user.totp_secret else '' }}">
    {% trans %}
    Add <abbr title="two factor authentication">2FA</abbr> with authentication application
  {% endtrans %}
</a>
<a href="{{ request.route_path('manage.account.webauthn-provision') }}"
   class="button button--primary {{ "button--disabled" if disabled else "" }}"
   id="webauthn-button"
   aria-describedby="webauthn-errors">
  {% trans %}
  Add <abbr title="two factor authentication">2FA</abbr> with security device (e.g. USB key)
{% endtrans %}
</a>
</div>
<noscript>
  <p>
    {% trans %}Enable JavaScript to set up two factor authentication with a security device (e.g. USB key){% endtrans %}
  </p>
</noscript>
<ul id="webauthn-errors" class="form-errors form-errors--full-width">
  <li id="webauthn-browser-support" class="hidden margin-top--large">
    {% trans href='https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredential#Browser_compatibility', title=gettext('External link') %}
    <a href="{{ href }}" title="{{ title }}" target="_blank" rel="noopener">Upgrade your browser</a> to set up two factor authentication with a security device (e.g. USB key)
  {% endtrans %}
</li>
</ul>
</section>
{% endmacro %}
{% block content %}
  <div class="tabs-container">
    {% block breadcrumbs %}
      <nav aria-label="{% trans %}Breadcrumbs{% endtrans %}" class="breadcrumbs">
        <ul>
          {# Last breadcrumb can be overriden #}
          {% block breadcrumb %}
            <li class="breadcrumbs__breadcrumb">{% trans %}Your account{% endtrans %}</li>
          {% endblock %}
        </ul>
      </nav>
    {% endblock %}
    <div class="vertical-tabs">
      <div class="vertical-tabs__tabs">
        <div class="sidebar-section">
          <nav aria-label="{% trans %}Account navigation{% endtrans %}">
            <ul class="vertical-tabs__list">
              <li>
                <a href="{{ request.route_path('manage.projects') }}"
                   class="vertical-tabs__tab vertical-tabs__tab--with-icon {% if active_tab == 'projects' %}vertical-tabs__tab--is-active{% endif %}"
                   {% if active_tab == 'projects' %}aria-selected="true"{% endif %}>
                  <i class="fa fa-lg fa-cubes" aria-hidden="true"></i>
                  {% trans %}Your projects{% endtrans %}
                </a>
              </li>
              {% if request.organization_access %}
                <li>
                  <a href="{{ request.route_path('manage.organizations') }}"
                     class="vertical-tabs__tab vertical-tabs__tab--with-icon {% if active_tab == 'organizations' %}vertical-tabs__tab--is-active{% endif %}"
                     {% if active_tab == 'organizations' %}aria-selected="true"{% endif %}>
                    <i class="fa fa-sitemap" aria-hidden="true"></i>
                    {% trans %}Your organizations{% endtrans %}
                  </a>
                </li>
              {% endif %}
              <li>
                <a href="{{ request.route_path('manage.account') }}"
                   class="vertical-tabs__tab vertical-tabs__tab--with-icon {% if active_tab == 'account' %}vertical-tabs__tab--is-active{% endif %}"
                   {% if active_tab == 'account' %}aria-selected="true"{% endif %}>
                  <i class="fa fa-cog" aria-hidden="true"></i>
                  {% trans %}Account settings{% endtrans %}
                </a>
              </li>
              <li>
                <a href="{{ request.route_path('manage.account.publishing') }}"
                   class="vertical-tabs__tab vertical-tabs__tab--with-icon {% if active_tab == 'publishing' %}vertical-tabs__tab--is-active{% endif %}"
                   {% if active_tab == 'publishing' %}aria-selected="true"{% endif %}>
                  <i class="fa fa-upload" aria-hidden="true"></i>
                  {% trans %}Publishing{% endtrans %}
                </a>
              </li>
            </ul>
          </nav>
        </div>
      </div>
      <div class="vertical-tabs__panel">
        <!-- mobile nav -->
        <nav aria-label="{% trans %}Account navigation{% endtrans %}">
          <ul class="vertical-tabs__list">
            <li>
              <a href="{{ request.route_path('manage.projects') }}"
                 class="vertical-tabs__tab vertical-tabs__tab--mobile vertical-tabs__tab--with-icon vertical-tabs__tab--no-top-border {% if active_tab == 'projects' %}vertical-tabs__tab--is-active{% endif %}"
                 {% if active_tab == 'projects' %}aria-selected="true"{% endif %}>
                <i class="fa fa-lg fa-cubes" aria-hidden="true"></i>
                {% trans %}Your projects{% endtrans %}
              </a>
            </li>
            {% if request.organization_access %}
              <li>
                <a href="{{ request.route_path('manage.organizations') }}"
                   class="vertical-tabs__tab vertical-tabs__tab--mobile vertical-tabs__tab--with-icon vertical-tabs__tab--no-top-border {% if active_tab == 'organizations' %}vertical-tabs__tab--is-active{% endif %}"
                   {% if active_tab == 'organizations' %}aria-selected="true"{% endif %}>
                  <i class="fa fa-sitemap" aria-hidden="true"></i>
                  {% trans %}Your organizations{% endtrans %}
                </a>
              </li>
            {% endif %}
            <li>
              <a href="{{ request.route_path('manage.account') }}"
                 class="vertical-tabs__tab vertical-tabs__tab--mobile vertical-tabs__tab--with-icon vertical-tabs__tab--no-top-border {% if active_tab == 'account' %}vertical-tabs__tab--is-active{% endif %}"
                 {% if active_tab == 'account' %}aria-selected="true"{% endif %}>
                <i class="fa fa-cog" aria-hidden="true"></i>
                {% trans %}Account settings{% endtrans %}
              </a>
            </li>
            <li>
              <a href="{{ request.route_path('manage.account.publishing') }}"
                 class="vertical-tabs__tab vertical-tabs__tab--mobile vertical-tabs__tab--with-icon vertical-tabs__tab--no-top-border {% if active_tab == 'publishing' %}vertical-tabs__tab--is-active{% endif %}"
                 {% if active_tab == 'publishing' %}aria-selected="true"{% endif %}>
                <i class="fa fa-upload" aria-hidden="true"></i>
                {% trans %}Publishing{% endtrans %}
              </a>
            </li>
          </ul>
        </nav>
        <div class="vertical-tabs__content">
          {% block main %}{% endblock %}
        </div>
      </div>
    </div>
  </div>
{% endblock %}
{% macro modal_slug(title, index) %}
{% endmacro %}
{% macro confirm_modal(
  title,
  label,
  confirm_name,
  confirm_string,
  slug,
  context,
  confirm_button_label=None,
  extra_fields=None,
  extra_description=None,
  action=None,
  method="POST",
  warning=True,
  custom_warning_text="",
  confirm_string_in_title=True,
  modifier="--danger")
  %}
  <div id="{{ slug }}"
       class="modal"
       data-controller="{% if confirm_string %}confirm {% endif %}modal-close">
    <div class="modal__content" role="dialog">
      <a href="#modal-close"
         data-action="click->modal-close#cancel"
         title="{% trans %}Close{% endtrans %}"
         class="modal__close">
        <i class="fa fa-times" aria-hidden="true"></i>
        <span class="sr-only">{% trans %}Close{% endtrans %}</span>
      </a>
      <form method="{{ method }}"
            class="modal__form"
            action="{{ action or request.current_route_path() }}">
        <input name="csrf_token"
               type="hidden"
               value="{{ request.session.get_csrf_token() }}">
        <div class="modal__body">
          <h3 class="modal__title">
            {{ title }}
            {% if confirm_string_in_title and confirm_string %}'{{ confirm_string }}'{% endif %}
            ?
          </h3>
          {% if warning %}
            <div class="callout-block callout-block--danger callout-block--bottom-margin no-top-margin">
              <p>
                <i class="fa fa-exclamation-triangle" aria-hidden="true"><span class="sr-only">{% trans %}Warning{% endtrans %}</span></i>
                {% trans %}This action cannot be undone!{% endtrans %}
              </p>
              {% if custom_warning_text %}{{ custom_warning_text }}{% endif %}
            </div>
          {% endif %}
          {{ extra_description if extra_description else '' }}
          <div class="form-group">{{ extra_fields if extra_fields else '' }}</div>
          {% if confirm_string %}
            <p>
              {% if confirm_name == 'username' %}
                {% trans %}Confirm your username to continue.{% endtrans %}
              {% else %}
                {% trans item=label|lower %}Confirm the {{ item }} to continue.{% endtrans %}
              {% endif %}
            </p>
            {% set name = "confirm_" + confirm_name.lower().replace(' ', '_') %}
            <div class="form-group">
              <label for="{{ slug }}-{{ name }}">{{ label }}</label>
              <input id="{{ slug }}-{{ name }}"
                     name="{{ name }}"
                     data-action="input->confirm#check"
                     data-confirm-target="input"
                     data-modal-close-target="input"
                     type="text"
                     autocomplete="off"
                     autocapitalize="off"
                     spellcheck="false">
            </div>
          {% endif %}
        </div>
        <div class="modal__footer">
          <button type="reset"
                  class="button modal__action js-cancel"
                  data-action="click->modal-close#cancel">{% trans %}Cancel{% endtrans %}</button>
          <button type="submit"
                  class="button button{{ modifier or '--primary' }} modal__action js-confirm"
                  {% if confirm_string %}data-confirm-target="button" data-expected="{{ confirm_string }}"{% endif %}
                  data-modal-close-target="button">
            {{ confirm_button_label if confirm_button_label else title }}
          </button>
        </div>
      </form>
    </div>
  </div>
{% endmacro %}
{% macro confirm_password_modal(
  title,
  slug,
  confirm_button_label=None,
  extra_fields=None,
  action=None,
  warning=True,
  custom_warning_text=""
  ) %}
  <div id="{{ slug }}"
       class="modal"
       data-controller="confirm-password modal-close">
    <div class="modal__content" role="dialog">
      <a href="#modal-close"
         data-action="click->modal-close#cancel"
         title="Close"
         class="modal__close">
        <i class="fa fa-times" aria-hidden="true"></i>
        <span class="sr-only">{% trans %}close{% endtrans %}</span>
      </a>
      <form method="post"
            class="modal__form"
            action="{{ action or request.current_route_path() }}">
        <input name="csrf_token"
               type="hidden"
               value="{{ request.session.get_csrf_token() }}">
        {{ extra_fields if extra_fields else '' }}
        <div class="modal__body">
          <h3 class="modal__title">{{ title }}</h3>
          {% if warning %}
            <div class="callout-block callout-block--danger callout-block--bottom-margin no-top-margin">
              <p>
                <i class="fa fa-exclamation-triangle" aria-hidden="true"><span class="sr-only">{% trans %}Warning{% endtrans %}</span></i>
                {% trans %}This action cannot be undone!{% endtrans %}
              </p>
              {% if custom_warning_text %}{{ custom_warning_text }}{% endif %}
            </div>
          {% endif %}
          <p>{% trans %}Enter your password to continue.{% endtrans %}</p>
          <div class="form-group">
            <div class="split-layout">
              <label for="confirm_password">{% trans %}Password{% endtrans %}</label>
              <label for="show-confirm-password-{{ slug }}" class="show-password">
                <input data-action="change->confirm-password#setPasswordVisibility"
                       data-confirm-password-target="showPassword"
                       id="show-confirm-password-{{ slug }}"
                       type="checkbox">
                {% trans %}Show password{% endtrans %}
              </label>
            </div>
            <input name="confirm_password"
                   data-action="input->confirm-password#check"
                   data-confirm-password-target="password"
                   data-modal-close-target="input"
                   type="password"
                   autocomplete="off"
                   autocorrect="off"
                   autocapitalize="off">
          </div>
        </div>
        <div class="modal__footer">
          <button type="reset"
                  class="button modal__action js-cancel"
                  data-action="click->modal-close#cancel">{% trans %}Cancel{% endtrans %}</button>
          <button type="submit"
                  class="button button--danger modal__action js-confirm"
                  data-confirm-password-target="button"
                  data-modal-close-target="button">{{ confirm_button_label }}</button>
        </div>
      </form>
    </div>
  </div>
{% endmacro %}
{% macro confirm_button(
  title,
  label,
  confirm_name,
  confirm_string,
  confirm_button_label=None,
  extra_fields=None,
  extra_description=None,
  action=None,
  warning=True,
  confirm_string_in_title=True,
  modifier="--danger",
  tooltip=None,
  additional_attributes=None)
  %}
  {% set slug = confirm_name.lower().replace(' ', '-') + '-modal' %}
  <a href="#{{ slug }}"
     class="button button{{ modifier }}"
     {% if tooltip != None %}title="{{ tooltip }}"{% endif %}
     {{ additional_attributes or '' }}>
    {{ confirm_button_label if confirm_button_label else title }}
  </a>
  {{ confirm_modal(title, label, confirm_name, confirm_string, slug, confirm_button_label=confirm_button_label, extra_fields=extra_fields, extra_description=extra_description, action=action, warning=warning, confirm_string_in_title=confirm_string_in_title, modifier=modifier) }}
{% endmacro %}
{% macro confirm_password_button(
  title,
  extra_fields=None,
  action=None
  )
  %}
  {% set slug = title.lower().replace(' ', '-') + '-modal' %}
  <a href="#{{ slug }}" class="button button--danger">{{ title }}</a>
  {{ confirm_password_modal(title, slug, confirm_button_label=title, extra_fields=extra_fields, action=action) }}
{% endmacro %}
{% macro form_error_anchor(form) %}
  {% if form.errors %}<div id="errors"></div>{% endif %}
{% endmacro %}
{% macro form_errors(form) %}
  {% if form.form_errors %}
    <ul class="form-errors" role="alert">
      {% for error in form.form_errors %}<li>{{ error }}</li>{% endfor %}
    </ul>
  {% endif %}
{% endmacro %}
{% macro field_errors(field) %}
  {% if field.errors %}
    <ul id="{{ field.name }}-errors" class="form-errors" role="alert">
      {% for error in field.errors %}<li>{{ error }}</li>{% endfor %}
    </ul>
  {% endif %}
{% endmacro %}
{% macro oidc_title() %}
  {% trans %}Trusted Publisher Management{% endtrans %}
{% endmacro %}
{% macro oidc_desc() %}
  <p>
    {% trans %}
    OpenID Connect (OIDC) provides a flexible, credential-free mechanism for delegating
    publishing authority for a PyPI package to a trusted third party service,
    like GitHub Actions.
  {% endtrans %}
</p>
<p>
  {% trans %}
  PyPI users and projects can use trusted publishers to automate
  their release processes, without needing to use API tokens or passwords.
{% endtrans %}
</p>
<p class="no-bottom-padding">
  {% trans href="https://docs.pypi.org/trusted-publishers/" %}
  You can read more about trusted publishers and how to use them
  <a href="{{ href }}">here</a>.
{% endtrans %}
</p>
{% endmacro %}
{% macro oidc_publisher_row(publisher) -%}
  {# project_name is only defined for pending OIDC publishers -#}
  {% if publisher.project_name is defined %}
    {% set delete_route = request.route_path('manage.account.publishing') %}
  {% else %}
    {% set delete_route = request.route_path('manage.project.settings.publishing', project_name=project.name) %}
  {% endif %}
  <tr>
    {% if publisher.project_name is defined %}<td scope="row">{{ publisher.project_name }}</td>{% endif %}
    <td scope="row">{{ publisher.publisher_name }}</td>
    <td scope="row">
      <small>
        {% if publisher.publisher_name == "GitHub" %}
          <b>Repository:</b> <a href="{{ publisher.publisher_url() }}">{{ publisher.repository }}</a>
          <br>
          <b>Workflow:</b> {{ publisher.workflow_filename }}
          <br>
          <b>Environment name:</b>
          {% if publisher.environment %}
            {{ publisher.environment }}
          {% else %}
            <i>({% trans %}Any{% endtrans %})</i>
          {% endif %}
        {% elif publisher.publisher_name == "GitLab" %}
          <b>Project:</b> <a href="{{ publisher.publisher_url() }}">{{ publisher.project_path }}</a>
          <br>
          <b>Top-level pipeline:</b> {{ publisher.workflow_filepath }}
          <br>
          <b>Environment name:</b>
          {% if publisher.environment %}
            {{ publisher.environment }}
          {% else %}
            <i>({% trans %}Any{% endtrans %})</i>
          {% endif %}
          <br>
          <b>Issuer:</b> {{ publisher.issuer_url }}
        {% elif publisher.publisher_name == "Google" %}
          <b>Email:</b> {{ publisher.email }}
          <br>
          <b>Subject:</b>
          {% if publisher.sub %}
            {{ publisher.sub }}
          {% else %}
            <i>({% trans %}Any{% endtrans %})</i>
          {% endif %}
        {% elif publisher.publisher_name == "ActiveState" %}
          <b>Organization:</b> {{ publisher.organization }}
          <br>
          <b>ActiveState Project:</b> <a href="{{ publisher.publisher_url() }}">{{ publisher.project }}</a>
          <br>
          <b>Actor:</b> {{ publisher.actor }}
          <br>
        {% else %}
          -
        {% endif %}
      </small>
    </td>
    <td scope="row">
      <a href="#remove-publisher-{{ publisher.id }}"
         class="button button--danger">{% trans %}Remove{% endtrans %}</a>
    </td>
  </tr>
  {# Confirmation modal for removing the publisher #}
  {% set slug = "remove-publisher-" ~ publisher.id %}
  {% set title = gettext("Remove trusted publisher") %}
  {% set extra_description %}
    <p>
      {% trans publisher_name=publisher.publisher_name %}Removing this {{ publisher_name }} trusted publisher will prevent automated package uploads from this source. You can re-add it later if needed.{% endtrans %}
    </p>
  {% endset %}
  {% set extra_fields %}
    <input name="publisher_id" type="hidden" value="{{ publisher.id }}">
  {% endset %}
  {{ confirm_modal(title=title, label=publisher.publisher_name, confirm_name="", confirm_string="", slug=slug, context=None, extra_description=extra_description, extra_fields=extra_fields, action=delete_route, warning=False, confirm_button_label=gettext("Remove publisher") ) }}
{%- endmacro %}
{% macro oidc_audit_event(event) -%}
  {% if event.tag == EventTag.Project.OIDCPublisherAdded or event.tag == EventTag.Account.PendingOIDCPublisherAdded %}
    {% set submit_desc = _("Added by:") %}
  {% elif event.tag == EventTag.Project.OIDCPublisherRemoved or event.tag == EventTag.Account.PendingOIDCPublisherRemoved %}
    {% set submit_desc = _("Removed by:") %}
  {% else %}
    {% set submit_desc = _("Submitted by:") %}
  {% endif %}
  {% if event.additional.publisher == "GitHub" %}
    {% set specifier_desc = _("Workflow:") %}
  {% else %}
    {% set specifier_desc = _("Specifier:") %}
  {% endif %}
  <small>{% trans %}Publisher:{% endtrans %} {{ event.additional.publisher }}</small>
  {% if event.additional.url %}
    <small>{% trans %}URL:{% endtrans %} {{ event.additional.url }}</small>
  {% endif %}
  <small>{{ specifier_desc }} {{ event.additional.specifier }}</small>
  {% if event.additional.submitted_by %}
    <small>
      {{ submit_desc }} <a href="{{ request.route_path('accounts.profile', username=event.additional.submitted_by) }}">{{ event.additional.submitted_by }}</a>
    </small>
  {% endif %}
{%- endmacro %}
